package com.zxy.furns.web;/**
 * ClassName: MemberServlet
 * Package: com.zxy.furns.web
 *
 * @Author zxy
 * @Create 2025/3/21 14:21
 * @Version 1.0
 * title:
 * Description:
 */

import com.zxy.furns.service.MemberService;
import com.zxy.furns.service.impl.MemberServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.lang.annotation.Target;
import java.lang.reflect.Method;


public class BasicServlet extends HttpServlet {
    private MemberService memberService = new MemberServiceImpl();


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        String action = req.getParameter("action");
        System.out.println("action = " + action);

        try {
            Method declaredMethod = this.getClass().getDeclaredMethod(action, HttpServletRequest.class, HttpServletResponse.class);
            System.out.println("declaredMethod方法是 = " + declaredMethod);
            //使用方法对象，进行反射调用
            declaredMethod.invoke(this,req,resp);
            System.out.println("调用反射机制成功！！！！...");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
}